import Vue from 'vue';
import App from './muke/app.vue';
import ElementUI from 'element-ui';
import 'element-ui/lib/theme-chalk/index.css';
import Router from 'vue-router';
import axios from 'axios';
import VueAxios from 'vue-axios';
import store from './muke/store/index';
import './muke/assets/styles/main.css';
import './muke/assets/icons/index.js';

//注册全局组件
const r1 = require.context('./muke/components',true,/\.vue$/);
const m1 = r1.keys().reduce((m1,filepath)=>{
    let k = filepath.replace(/(.*\/)*([^.]+).*/ig,"$2");
    let value = r1(filepath);
    m1[k] = value.default;
    return m1;
},{});
Object.keys(m1).forEach(k=>{
    Vue.component(k,m1[k]);
});

//注册自定义指令
import * as directives from './muke/directives';
Object.keys(directives).forEach(k=>{
    Vue.directive(k,directives[k]);
});

//引入路由
import router from './muke/router/index';

Vue.use(VueAxios,axios);
Vue.use(ElementUI);
Vue.use(Router);

const rootdiv = document.createElement('div');
document.body.appendChild(rootdiv);

new Vue({
    store,
    router,
    render:(h)=>h(App)
}).$mount(rootdiv);